﻿using FileToVideo.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FileToVideo.AddFunc
{
    /// <summary>
    /// String 追加方法
    /// </summary>
    public static class StringAdd
    {
        /// <summary>
        /// 重复拼接字符串
        /// </summary>
        /// <param name="content"></param>
        /// <param name="RepeatCount"></param>
        /// <returns></returns>
        public static string Repeat(this string content,int RepeatCount)
        {
            var ret = new StringBuilder();
            for (int i = 0; i < RepeatCount; i++)
            {
                ret.Append(content);
            }
            return ret.ToString();
        }

        /// <summary>
        /// 根据1080P分辨率分块大小，分割字符串
        /// </summary>
        /// <param name="content"></param>
        /// <param name="partSize"></param>
        /// <returns></returns>
        public static List<string> SplitByPartSize(this string content, PartSizeMode_1080P partSize)
        {
            var partSizeLength = partSize.FrameSizeNoError();
            if(partSizeLength == int.MaxValue) return null;

            var ret = new List<string>();
            for (int i = 0; i < content.Length; i += partSizeLength)
            {
                ret.Add(content.Substring(i, partSizeLength));
            }
            return ret;
        }
    }
}
